package android.slc.appbase.vm;

import android.slc.appbase.vmbox.WindowVmBox;
import android.slc.commonlibrary.CacheMemoryUtils;
import android.slc.module.component.dict.vmbox.TreeDictVmBox;

/**
 * 全局数据
 *
 * @author slc
 * @date 2020-08-18 17:37
 */
public class GlobalDataVm {
    private static final GlobalDataVm globalDataVm = new GlobalDataVm();
    public final TreeDictVmBox treeDictVmBox = new TreeDictVmBox();

    private final CacheMemoryUtils baseCacheMemoryUtils = CacheMemoryUtils.getInstance("baseCache", 512);
    public final WindowVmBox windowVmBox = new WindowVmBox();

    public static GlobalDataVm getInstance() {
        return globalDataVm;
    }

    public <T> T getData(String key) {
        return baseCacheMemoryUtils.get(key);
    }

    public void putData(String key, Object value) {
        baseCacheMemoryUtils.put(key, value);
    }

    public void clearAllData() {
        baseCacheMemoryUtils.clear();
        treeDictVmBox.clear();
    }
}
